namespace DuToanT2.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class HangMuc : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.HangMuc_CongViec",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        KhoiLuong = c.Double(nullable: false),
                        HangMucId = c.Int(nullable: false),
                        DinhMuc_CongViecId = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.HangMuc", t => t.HangMucId, cascadeDelete: true)
                .ForeignKey("dbo.DinhMuc_CongViec", t => t.DinhMuc_CongViecId, cascadeDelete: true)
                .Index(t => t.HangMucId)
                .Index(t => t.DinhMuc_CongViecId);
            
            CreateTable(
                "dbo.HangMuc",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 150),
                        Description = c.String(maxLength: 150),
                        ProjectId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Project", t => t.ProjectId, cascadeDelete: true)
                .Index(t => t.ProjectId);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.HangMuc", new[] { "ProjectId" });
            DropIndex("dbo.HangMuc_CongViec", new[] { "DinhMuc_CongViecId" });
            DropIndex("dbo.HangMuc_CongViec", new[] { "HangMucId" });
            DropForeignKey("dbo.HangMuc", "ProjectId", "dbo.Project");
            DropForeignKey("dbo.HangMuc_CongViec", "DinhMuc_CongViecId", "dbo.DinhMuc_CongViec");
            DropForeignKey("dbo.HangMuc_CongViec", "HangMucId", "dbo.HangMuc");
            DropTable("dbo.HangMuc");
            DropTable("dbo.HangMuc_CongViec");
        }
    }
}
